package com.ptszyxx.popose.module.main.mine.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ItemMineFollowBinding;
import com.ptszyxx.popose.module.main.mine.vm.MineFollowTabVM;
import com.ysg.http.data.entity.mine.FollowEntity;
import com.ysg.widget.button.YSelectButton;

public class MineFollowAdapter extends BaseQuickAdapter<FollowEntity, BaseDataBindingHolder<ItemMineFollowBinding>> {

    private MineFollowTabVM viewModel;

    public MineFollowAdapter(MineFollowTabVM viewModel) {
        super(R.layout.item_mine_follow);
        this.viewModel = viewModel;
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemMineFollowBinding> holder, FollowEntity item) {
        ItemMineFollowBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setEntity(item);
            binding.setViewModel(viewModel);
            binding.setPosition(holder.getBindingAdapterPosition());
            binding.executePendingBindings();

            binding.tvFollow.setOnSelectButtonListener(new YSelectButton.OnSelectButtonListener() {
                @Override
                public void onClickListener() {
                    viewModel.onFollowClick(item, holder.getBindingAdapterPosition());
                }
            });

        }
    }








}
